<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>地址管理 - 邦伴用户端</title>
  <link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">
  <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css" rel="stylesheet">
  <style>
    :root {
      --primary: #ff7e2d;
      --primary-light: #fff3ea;
      --border: #f0f0f0;
      --text-main: #222;
      --text-sub: #888;
    }
    
    body {
      font-family: 'PingFang SC', 'Helvetica Neue', Arial, sans-serif;
      background-color: #f8f8f8;
      color: var(--text-main);
    }
    
    .app-container {
      width: 375px;
      height: 812px;
      margin: 0 auto;
      background: #fff;
      position: relative;
      box-shadow: 0 0 10px rgba(0, 0, 0, 0.05);
      overflow-y: auto;
    }
    
    .primary-color {
      color: var(--primary);
    }
    
    .primary-bg {
      background-color: var(--primary);
    }
    
    .primary-light-bg {
      background-color: var(--primary-light);
    }
    
    .btn-primary {
      background-color: var(--primary);
      color: white;
    }
    
    .btn-outline {
      border: 1px solid var(--primary);
      color: var(--primary);
    }
    
    .card {
      border-radius: 12px;
      box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    }
    
    .address-card {
      border: 1px solid var(--border);
      border-radius: 12px;
      padding: 16px;
      margin-bottom: 16px;
      position: relative;
    }
    
    .address-card.default {
      border-color: var(--primary);
      background-color: var(--primary-light);
    }
    
    .default-tag {
      background-color: var(--primary);
      color: white;
      font-size: 10px;
      padding: 2px 6px;
      border-radius: 4px;
      position: absolute;
      top: 16px;
      right: 16px;
    }
  </style>
</head>
<body>
  <div class="app-container">
    <!-- 顶部导航栏 -->
    <div class="sticky top-0 z-10 bg-white border-b border-gray-100 px-4 py-3 flex items-center">
      <a href="javascript:history.back()" class="mr-2">
        <i class="fas fa-arrow-left text-lg"></i>
      </a>
      <h1 class="text-lg font-medium flex-1 text-center">地址管理</h1>
    </div>
    
    <!-- 地址列表 -->
    <div class="p-4">
      <!-- 默认地址 -->
      <div class="address-card default">
        <span class="default-tag">默认</span>
        <div class="flex items-start mb-2">
          <h3 class="font-medium">张先生</h3>
          <span class="ml-3 text-gray-500">138****6789</span>
        </div>
        <p class="text-gray-600 text-sm mb-3">上海市浦东新区张江高科技园区博云路2号浦软大厦6楼</p>
        <div class="flex justify-between items-center">
          <div class="flex items-center">
            <div class="w-5 h-5 rounded-full border border-primary flex items-center justify-center mr-2">
              <div class="w-3 h-3 rounded-full primary-bg"></div>
            </div>
            <span class="text-sm">设为默认</span>
          </div>
          <div class="flex">
            <a href="address_edit.html?id=1" class="flex items-center text-gray-500 mr-4">
              <i class="fas fa-edit mr-1"></i>
              <span class="text-sm">编辑</span>
            </a>
            <a href="#" class="flex items-center text-gray-500 delete-address" data-id="1">
              <i class="fas fa-trash-alt mr-1"></i>
              <span class="text-sm">删除</span>
            </a>
          </div>
        </div>
      </div>
      
      <!-- 其他地址 -->
      <div class="address-card">
        <div class="flex items-start mb-2">
          <h3 class="font-medium">李女士</h3>
          <span class="ml-3 text-gray-500">139****5678</span>
        </div>
        <p class="text-gray-600 text-sm mb-3">上海市静安区南京西路1266号恒隆广场46楼</p>
        <div class="flex justify-between items-center">
          <div class="flex items-center">
            <div class="w-5 h-5 rounded-full border border-gray-300 flex items-center justify-center mr-2">
              <div class="w-3 h-3 rounded-full bg-white"></div>
            </div>
            <span class="text-sm">设为默认</span>
          </div>
          <div class="flex">
            <a href="address_edit.html?id=2" class="flex items-center text-gray-500 mr-4">
              <i class="fas fa-edit mr-1"></i>
              <span class="text-sm">编辑</span>
            </a>
            <a href="#" class="flex items-center text-gray-500 delete-address" data-id="2">
              <i class="fas fa-trash-alt mr-1"></i>
              <span class="text-sm">删除</span>
            </a>
          </div>
        </div>
      </div>
      
      <div class="address-card">
        <div class="flex items-start mb-2">
          <h3 class="font-medium">王先生</h3>
          <span class="ml-3 text-gray-500">136****2345</span>
        </div>
        <p class="text-gray-600 text-sm mb-3">上海市徐汇区虹桥路3号港汇广场2座12楼</p>
        <div class="flex justify-between items-center">
          <div class="flex items-center">
            <div class="w-5 h-5 rounded-full border border-gray-300 flex items-center justify-center mr-2">
              <div class="w-3 h-3 rounded-full bg-white"></div>
            </div>
            <span class="text-sm">设为默认</span>
          </div>
          <div class="flex">
            <a href="address_edit.html?id=3" class="flex items-center text-gray-500 mr-4">
              <i class="fas fa-edit mr-1"></i>
              <span class="text-sm">编辑</span>
            </a>
            <a href="#" class="flex items-center text-gray-500 delete-address" data-id="3">
              <i class="fas fa-trash-alt mr-1"></i>
              <span class="text-sm">删除</span>
            </a>
          </div>
        </div>
      </div>
    </div>
    
    <!-- 底部添加按钮 -->
    <div class="fixed bottom-0 left-0 right-0 p-4 bg-white border-t border-gray-100" style="width: 375px; margin: 0 auto;">
      <a href="address_add.html" class="block w-full py-3 btn-primary text-center rounded-lg">
        <i class="fas fa-plus mr-2"></i>新增收货地址
      </a>
    </div>
    
    <!-- 删除确认弹窗 -->
    <div id="deleteModal" class="fixed inset-0 bg-black bg-opacity-50 hidden flex items-center justify-center z-50">
      <div class="bg-white rounded-lg w-72 overflow-hidden">
        <div class="p-4 text-center">
          <h3 class="font-medium mb-2">确认删除</h3>
          <p class="text-sm text-gray-500">确定要删除该收货地址吗？</p>
        </div>
        <div class="flex border-t border-gray-100">
          <button id="cancelDelete" class="flex-1 py-3 text-center text-gray-500">取消</button>
          <button id="confirmDelete" class="flex-1 py-3 text-center primary-color">确定</button>
        </div>
      </div>
    </div>
  </div>

  <script>
    document.addEventListener('DOMContentLoaded', function() {
      // 设置默认地址
      const defaultCheckboxes = document.querySelectorAll('.w-5.h-5.rounded-full.border');
      defaultCheckboxes.forEach(checkbox => {
        checkbox.addEventListener('click', function() {
          // 移除所有默认样式
          document.querySelectorAll('.address-card').forEach(card => {
            card.classList.remove('default');
          });
          document.querySelectorAll('.default-tag').forEach(tag => {
            tag.remove();
          });
          document.querySelectorAll('.w-3.h-3.rounded-full').forEach(inner => {
            inner.classList.remove('primary-bg');
            inner.classList.add('bg-white');
          });
          document.querySelectorAll('.w-5.h-5.rounded-full.border').forEach(box => {
            box.classList.remove('border-primary');
            box.classList.add('border-gray-300');
          });
          
          // 设置新的默认地址
          const card = this.closest('.address-card');
          card.classList.add('default');
          const tag = document.createElement('span');
          tag.classList.add('default-tag');
          tag.textContent = '默认';
          card.appendChild(tag);
          this.classList.remove('border-gray-300');
          this.classList.add('border-primary');
          const inner = this.querySelector('.w-3.h-3.rounded-full');
          inner.classList.remove('bg-white');
          inner.classList.add('primary-bg');
          
          // 这里可以添加AJAX请求来保存默认地址设置
        });
      });
      
      // 删除地址
      const deleteButtons = document.querySelectorAll('.delete-address');
      const deleteModal = document.getElementById('deleteModal');
      const cancelDelete = document.getElementById('cancelDelete');
      const confirmDelete = document.getElementById('confirmDelete');
      let addressToDelete = null;
      
      deleteButtons.forEach(button => {
        button.addEventListener('click', function(e) {
          e.preventDefault();
          addressToDelete = this.dataset.id;
          deleteModal.classList.remove('hidden');
          deleteModal.classList.add('flex');
        });
      });
      
      cancelDelete.addEventListener('click', function() {
        deleteModal.classList.add('hidden');
        deleteModal.classList.remove('flex');
        addressToDelete = null;
      });
      
      confirmDelete.addEventListener('click', function() {
        if (addressToDelete) {
          // 这里可以添加AJAX请求来删除地址
          const addressCard = document.querySelector(`.delete-address[data-id="${addressToDelete}"]`).closest('.address-card');
          addressCard.remove();
        }
        deleteModal.classList.add('hidden');
        deleteModal.classList.remove('flex');
        addressToDelete = null;
      });
      
      // 点击弹窗外部关闭
      deleteModal.addEventListener('click', function(e) {
        if (e.target === deleteModal) {
          deleteModal.classList.add('hidden');
          deleteModal.classList.remove('flex');
          addressToDelete = null;
        }
      });
    });
  </script>
</body>
</html> 